/* 签名提交
 * @Author: wujie 
 * @Date: 2018-06-12 11:06:22 
 * @Last Modified by: wujie
 * @Last Modified time: 2018-07-25 17:58:00
 */
import React,{ Component } from 'react'
import { Row } from 'antd'
import components from '@/components'
import { connect } from 'react-redux'
import actions from '@/actions/signEdit';
import util from '@/utils'

const { Card, SignEdit: Edit} = components

class SignEdit extends Component {
  
  render(){

    const props = util.pick(this.props, [
      'sign',
      'industry',
      'scenarios',
      'industryEnum',
      'scenariosEnum',
      'addButtonLoading',
    ])

    const funcProps = util.pick(this, [
      'onAdd',
      'onChangeSign',
      'onChangeIndustry',
      'onChangeScenarios'
    ])

    return (
      <div>
        <Card title="签名添加">
          <Row style={{padding: 24, backgroundColor: '#fff'}}>
            <Edit {...props} {...funcProps} />
          </Row>
        </Card>
      </div>
    )
  }

  componentDidMount() {
    this.props.getIndustryEnum()
    this.props.getScenariosEnum()
  }

  onChangeSign = ({ target:{ value }}) => {
    this.props.setSign(value)
  }

  onChangeIndustry = (val) => {
    this.props.setIndustry(val)
  }

  onChangeScenarios = (val) => {
    this.props.setScenarios(val)
  }

  onAdd = () => {
    this.props.add()
  }

}

const mapSateToProps = ({ signEditReducer }) => ({ ...signEditReducer })

const mapDispatchToProps = { ...actions }

export default connect(mapSateToProps, mapDispatchToProps)(SignEdit)